Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EUWE] Don't lookup category names if tag tree view all #13308

Merged
merged 1 commit into from
Jan 11, 2017

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Dec 22, 2016

When building the tag tree in access control groups, the tag tree is not expandable. But building the node name (using category.name) executes a few hundred extra queries (20%).

This skips those queries.

Numbers are for small 5_7 db. numbers in larger DBS will increase for each tag and node in the db. But they don't complete for me within a few minutes, so it was too hard to get numbers.

ms queries query (ms) rows comments`
2,604.9 591 289.8 869 /ops/explorer before
2,591.2 471 225.9 749 /ops/explorer after
20% 22.0% 14%

https://bugzilla.redhat.com/show_bug.cgi?id=1399345

This is the E version of #13301

@chessbyte chessbyte self-assigned this Dec 22, 2016
@kbrock
Copy link
Member Author

kbrock commented Dec 23, 2016

ugh, rails 5 and euwe. I'll rebase once we get euwe more rails friendly

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, but take a look at my comment about the return statement. Not sure why there is a difference there.

@@ -44,17 +44,26 @@ def root_options
end

def x_get_tree_roots(count_only, _options)
return @categories.size if count_only
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There a reason the return was removed from the "master" version of this PR: https://github.com/ManageIQ/manageiq-ui-classic/pull/57/files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was probably an oversight. May have to put in a PR to get this line into master

else
kid_id = "#{parent.name}-#{kid.name}"
(@edit && @edit.fetch_path(:new, :filters, kid_id)) || (@filters && @filters.key?(kid_id))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the main savings here, correct? We are just avoiding building kid_id for each node since it is not used when @edit and @filters are blank, correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, just noticed that contain_selected_kid is basically this exact same logic. Is it possible to refactor this so we don't have so much code duplication?

This is minor, don't bother if it isn't worth it. Also, we have already merged this in master, so we would probably want to go back and do this there as well, which might be a pain.

@kbrock kbrock force-pushed the config_groups_euwe branch 2 times, most recently from 1afeb3d to 5904f18 Compare January 5, 2017 21:14
@miq-bot
Copy link
Member

miq-bot commented Jan 5, 2017

Checked commit kbrock@5904f18 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
1 file checked, 0 offenses detected
Everything looks good. 🏆

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh... after my suggestions... now I see an issue with has_key_path?...

kids = parent.entries.map do |kid|
kid_id = "#{parent.name}-#{kid.name}"
select = (@edit && @edit.fetch_path(:new, :filters, kid_id)) || (@filters && @filters.key?(kid_id))
select = selected_entry_value(parent, kid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have asked this before... was this supposed to be a boolean or the value for that key? Seems like it should have been the value, but not sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks - fixed

@kbrock
Copy link
Member Author

kbrock commented Jan 7, 2017

@NickLaMuro is this better?

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I think I probably had you do a bit more than was necessary to get the job done, so thanks for the extra work. 👍

This was executing a few hundred extra queries

category.name is the culprit

https://bugzilla.redhat.com/show_bug.cgi?id=1399345
@kbrock kbrock force-pushed the config_groups_euwe branch from 24ab41c to c6fb39b Compare January 7, 2017 23:36
@kbrock
Copy link
Member Author

kbrock commented Jan 7, 2017

@NickLaMuro cool. I changed x_get_tree_roots to use a guard clause like all the other methods.

Will put in a master PR to get these changes into there.

@simaishi simaishi merged commit cea5f55 into ManageIQ:euwe Jan 11, 2017
@kbrock kbrock deleted the config_groups_euwe branch January 11, 2017 14:42
@kbrock kbrock added the ui label Jan 12, 2017
@simaishi simaishi modified the milestone: Sprint 52 Ending Jan 16, 2017 Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants